﻿#include "promptdialog.h"
#include "ui_promptdialog.h"
#include <bitset>
#include <QDebug>

PromptDialog::PromptDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PromptDialog)
{
    ui->setupUi(this);

    setWindowFlags (Qt::Window | Qt::FramelessWindowHint);
    setWindowModality(Qt::ApplicationModal);

    setAttribute(Qt::WA_TranslucentBackground, true);
    connect(g_pMachine, SIGNAL(siMcInfoChange()), this, SLOT(slotMCInfoChange()));

    initDialog();
    initControl();
}

PromptDialog::~PromptDialog()
{
    delete ui;
}

//初始化窗体
void PromptDialog::initDialog(int sel)
{
    m_funType = sel;
    m_filePath.clear();

    m_spindleAngle = 0;//主轴旋转角度值
    m_length = 0;// 自动拉料长度
    m_area = 0;
    m_time = 0;//主轴研车-时间
    m_speed = 0;//主轴研车-速度

    setTitleStr("");
    setContentStr("");
    setContentProcessStr("");
    ui->labelContentInfo->setText("");
    ui->labeBreakHead->setText("");
    ui->buttonOk->setEnabled(true);

    ui->frameDetecBtn->hide();
    ui->frameTwo->hide();
    ui->frameThree->hide();
    ui->frameProcessBtn->hide();
    ui->frameWarrantBtn->hide();
    ui->frameProcess->hide();
    ui->frameChangePassword->hide();
    ui->frameSpindleRotate->hide();
    ui->frameWorkArea->hide();
    ui->frameHMIDecrypt->hide();
    ui->frameKnifePressure->hide();
    ui->frameFanArea->hide();
    ui->frameSpdSelect->hide();

    ui->labelContentInfo->hide();
    ui->labeBreakHead->hide();
    ui->labelContentProcess->hide();
    ui->labelContentWarrant->hide();

    ui->buttonForward->hide();//隐藏正转按钮
    ui->buttonReverse->hide();//隐藏反转按钮

    if (sel == BTN_OK_CANCEL)//确定、取消
    {
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if (sel == BTN_OK)//确定
    {
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonOk->move(m_btnCancelPoint);
    }
    else if (sel == BTN_R_R_S)//重命名、替换、跳过
    {
        ui->frameThree->show();
    }
    else if (sel == BTN_RESTART)//重启
    {
        ui->frameProcessBtn->show();
        ui->buttonRestart->show();
        ui->buttonUpdataCancel->hide();
        ui->buttonRestart->move(m_btnCancelPoint);
    }
    else if (sel == BTN_UCANCEL)//升级取消
    {
        ui->frameProcessBtn->show();
        ui->buttonRestart->hide();
        ui->buttonUpdataCancel->show();
    }
    else if (sel == BTN_WARRANT)//授权按钮
    {
        ui->frameWarrantBtn->show();
    }
    // 底线检测，面线检测
    else if(sel == BTN_BOTTOM || sel == BTN_FACE)
    {
        ui->frameDetecBtn->show();
    }
    else if(sel == BTN_NONE)//无按钮
    {
    }
    else if(sel == BTN_P_NONE)//无按钮
    {
    }
    else if(sel == BTN_HMI_DECRYPT)//界面解密
    {
        ui->frameHMIDecrypt->show();
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_CHANGE_PASSWORD)//修改一级密码
    {
        ui->frameChangePassword->show();
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_SPINDLE_ROTATE)//主轴旋转角度
    {
        ui->frameSpindleRotate->show();
        float angle = m_spindleAngle*0.01;
        QString angleStr;
        angleStr.sprintf("%.2f",angle);
        ui->buttonSpindleAngleValue->setText(angleStr);
        ui->labelSpindleAngle->setText(tr("Spindle angle"));
        ui->labelSpindleAngleUnit->setText(tr("deg"));
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
//        ui->buttonForward->show();//显示正转按钮
//        ui->buttonReverse->show();//显示反转按钮
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_ROTATE_ROTATE)//旋转电机旋转
    {
        ui->frameSpindleRotate->show();
        ui->buttonSpindleAngleValue->setText("0.00");
        ui->labelSpindleAngle->setText(tr("Rotate  angle"));
        ui->labelSpindleAngleUnit->setText(tr("deg"));
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
//        ui->buttonForward->show();//显示正转按钮
//        ui->buttonReverse->show();//显示反转按钮
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_SPINDLE_GRANDE)//主轴研车
    {
        ui->frameSpindleRotate->show();
        ui->buttonSpindleAngleValue->setText("0");
        ui->labelSpindleAngle->setText(tr("Spindle time"));
        ui->labelSpindleAngleUnit->setText(tr("s"));
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_AUTOMATIC_PULLMA)//自动拉料
    {
        ui->frameSpindleRotate->show();
        ui->buttonSpindleAngleValue->setText("0");
        ui->labelSpindleAngle->setText(tr("autoPull"));
        ui->labelSpindleAngleUnit->setText(tr("mm"));
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
//        ui->buttonForward->show();//显示正转按钮
//        ui->buttonReverse->show();//显示反转按钮
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_WORK_AREA)//设置可工作区域
    {
        ui->frameWorkArea->show();

        ui->buttonX1->setText(tr("X +"));
        ui->buttonX2->setText(tr("X  -"));
        ui->buttonY1->setText(tr("Y +"));
        ui->buttonY2->setText(tr("Y -"));
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonCancel->show();
        ui->buttonOk->move(m_btnOkPoint);
        ui->buttonCancel->move(m_btnCancelPoint);
    }
    else if(sel == BTN_KNIFE_PRESSURE)//刀压设置
    {
        ui->frameKnifePressure->show();
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonOk->move(m_btnCancelPoint);
        refreshMcPara();
    }
    else if(sel == BTN_FAN_AREA)//风机区域
    {
        ui->frameFanArea->show();
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonOk->move(m_btnCancelPoint);
        refreshWkPara();
    }
    else if(sel == BTN_SPD_SELECT)//平板切割速度选择
    {
        ui->frameSpdSelect->show();
        ui->frameTwo->show();
        ui->buttonOk->show();
        ui->buttonOk->move(m_btnCancelPoint);
        //发送下位机
        ParaStruct mcPara = g_pMachine->getMcPara();
        if(g_emMacType == MACHINE_FLATCUTTINGMAC)
        {
            m_speedStr1 = tr("Kn1Max:");
            m_speedStr2 = tr("Kn1Min:");
            m_speedStr3 = tr("Kn1Acc:");
            ui->buttonKn1_MaxSpd->setText(m_speedStr1+QString::number(mcPara.buf[167]));//刀1最大
            ui->buttonKn1_MinSpd->setText(m_speedStr2+QString::number(mcPara.buf[166]));//刀1最小
            ui->buttonKn1_AccSpd->setText(m_speedStr3+QString::number(mcPara.buf[168]));//刀1加速
        }
        else if(g_emMacType == MACHINE_DRAWING)
        {
            m_speedStr1 = tr("PenMax:");
            m_speedStr2 = tr("PenMin:");
            m_speedStr3 = tr("PenAcc:");
            ui->buttonKn1_MaxSpd->setText(m_speedStr1+QString::number(mcPara.buf[151]));//最大
            ui->buttonKn1_MinSpd->setText(m_speedStr2+QString::number(mcPara.buf[150]));//最小
            ui->buttonKn1_AccSpd->setText(m_speedStr3+QString::number(mcPara.buf[152]));//加速
            ui->buttonKn2_MaxSpd->hide();
            ui->buttonKn2_MinSpd->hide();
            ui->buttonKn2_AccSpd->hide();
        }

        //写数据
        ui->buttonKn2_MaxSpd->setText(tr("Kn2Max:")+QString::number(mcPara.buf[171]));//刀2最大
        ui->buttonKn2_MinSpd->setText(tr("Kn2Min:")+QString::number(mcPara.buf[170]));//刀2最小
        ui->buttonKn2_AccSpd->setText(tr("Kn2Acc:")+QString::number(mcPara.buf[172]));//刀2加速

        if(!g_pSettings->ifKeyExists("FlatPanelSpd/Model")){
            g_pSettings->writeToIniFile("FlatPanelSpd/Model",QVariant(1));

            for(int i = 1; i<6; i++){
                g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn1Min",QVariant(10));
                g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn1Max",QVariant(600));
                g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn1Acc",QVariant(500));
                g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn2Min",QVariant(10));
                g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn2Max",QVariant(600));
                g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn2Acc",QVariant(500));
            }

        }

        int model = g_pSettings->readFromIniFile("FlatPanelSpd/Model").toInt();
        // 根据名称查找指针id
        QRadioButton *searchedButton = this->findChild<QRadioButton *>("radioButtonSpd_" + QString::number(model));
        searchedButton->click();
    }

}

//初始化窗体控件，包括位置、尺寸、样式
void PromptDialog::initControl()
{
    //根据不同分辨率设置控件的位置和尺寸
    initResolution();
    initControlStyle();//初始化窗体控件样式
}

//初始化窗体控件为任意分辨率
void PromptDialog::initResolution()
{
    #define FRAME_LEFT         (259)      // 小窗口
    #define FRAME_TOP          (156)
    #define FRAME_WIGHT        (513)
    #define FRAME_HEIGHT       (291)

    #define TITLE_HEIGHT       (46)       // 标题栏高度

    double factoryX = getFactoryX();
    double factoryY = getFactoryY();

    //上状态栏
    this->resize(GLB_SCR_WIGHT*factoryX,GLB_SCR_HEIGHT*factoryY);
    this->move((GLB_SCR_WIGHT*factoryX-this->width())/2+g_mainWidgetPos.x(),(GLB_SCR_HEIGHT*factoryY-this->height())/2+g_mainWidgetPos.y());

    ui->frameBack->setGeometry(0*factoryX,0*factoryY,GLB_SCR_WIGHT*factoryX,GLB_SCR_HEIGHT*factoryY);
    ui->labelTitle->setGeometry((FRAME_LEFT+GLB_EDGE_WIGHT)*factoryX,(FRAME_TOP+(TITLE_HEIGHT-GLB_TEXT_HEIGHT)/2)*factoryY,(FRAME_WIGHT-GLB_TAB_WIGHT*2)*factoryX,GLB_TEXT_HEIGHT*factoryY);
    ui->labelContent->setGeometry((FRAME_LEFT+GLB_TAB_WIGHT)*factoryX ,(FRAME_TOP+GLB_EDGE_HEIGHT)*factoryY,
                                  (FRAME_WIGHT-GLB_TAB_WIGHT*2)*factoryX,(FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT*2)*factoryY);//(46,40,340,285)
    ui->labelContentInfo->setGeometry((FRAME_LEFT+GLB_TAB_WIGHT)*factoryX ,(FRAME_TOP+GLB_EDGE_HEIGHT)*factoryY,
                                      (FRAME_WIGHT-GLB_TAB_WIGHT*2)*factoryX,(FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT*2)*factoryY);//(46,40,350,285)

    ui->labeBreakHead->setGeometry(40*factoryX,40*factoryY,380*factoryX,285*factoryY);
    ui->labelContentWarrant->setGeometry(302*factoryX,193*factoryY,300*factoryX,225*factoryY);
    ui->frameProcess->setGeometry(145*factoryX,150*factoryY,800*factoryX,280*factoryY);//(20,70,480,130)
    ui->labelContentProcess->setGeometry(150*factoryX,80*factoryY,398*factoryX,40*factoryY);//(10,10,398,40)
    ui->progressBar->setGeometry(150*factoryX,120*factoryY,446*factoryX,26*factoryY);//进度条(10,50,446,26)

    ui->frameTwo->setGeometry(FRAME_LEFT*factoryX,
                              (FRAME_TOP+FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT)*factoryY,
                              FRAME_WIGHT*factoryX,
                              (GLB_LBUT_HEIGHT+GLB_EDGE_HEIGHT)*factoryY);
    ui->buttonForward->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*3)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonReverse->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*2)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonOk->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*1)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonCancel->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);

    m_btnOkPoint.setX((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*1)*factoryX);//ok按钮位置(284)
    m_btnOkPoint.setY(0*factoryY);
    m_btnCancelPoint.setX((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT)*factoryX);//cancel按钮位置(390)
    m_btnCancelPoint.setY(0*factoryY);


    ui->frameProcessBtn->setGeometry(FRAME_LEFT*factoryX,
                              (FRAME_TOP+FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT)*factoryY,
                              FRAME_WIGHT*factoryX,
                              (GLB_LBUT_HEIGHT+GLB_EDGE_HEIGHT)*factoryY);
    ui->buttonRestart->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*1)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonUpdataCancel->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);

    ui->frameWarrantBtn->setGeometry(FRAME_LEFT*factoryX,
                              (FRAME_TOP+FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT)*factoryY,
                              FRAME_WIGHT*factoryX,
                              (GLB_LBUT_HEIGHT+GLB_EDGE_HEIGHT)*factoryY);
    ui->buttonWarrant->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*1)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonWarrantCancel->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);

    ui->frameSpdSelect->setGeometry((FRAME_LEFT+25)*factoryX,(FRAME_TOP+58)*factoryY,455*factoryX,161*factoryY);

//    ui->buttonKn1_AccSpd->setSizePolicy();
    ui->radioButtonSpd_1->setText(tr("Spd1"));//速度1
    ui->radioButtonSpd_2->setText(tr("Spd2"));//速度2
    ui->radioButtonSpd_3->setText(tr("Spd3"));//速度3
    ui->radioButtonSpd_4->setText(tr("Spd4"));//速度4
    ui->radioButtonSpd_5->setText(tr("Spd5"));//速度5

    connect(ui->radioButtonSpd_1,SIGNAL(clicked(bool)),this,SLOT(slot_SpdSelect_clicked()));
    connect(ui->radioButtonSpd_2,SIGNAL(clicked(bool)),this,SLOT(slot_SpdSelect_clicked()));
    connect(ui->radioButtonSpd_3,SIGNAL(clicked(bool)),this,SLOT(slot_SpdSelect_clicked()));
    connect(ui->radioButtonSpd_4,SIGNAL(clicked(bool)),this,SLOT(slot_SpdSelect_clicked()));
    connect(ui->radioButtonSpd_5,SIGNAL(clicked(bool)),this,SLOT(slot_SpdSelect_clicked()));

    connect(ui->buttonKn1_MaxSpd,SIGNAL(clicked(bool)),this,SLOT(slot_buttonSpdParaModify_clicked()));
    connect(ui->buttonKn1_MinSpd,SIGNAL(clicked(bool)),this,SLOT(slot_buttonSpdParaModify_clicked()));
    connect(ui->buttonKn1_AccSpd,SIGNAL(clicked(bool)),this,SLOT(slot_buttonSpdParaModify_clicked()));
    connect(ui->buttonKn2_MaxSpd,SIGNAL(clicked(bool)),this,SLOT(slot_buttonSpdParaModify_clicked()));
    connect(ui->buttonKn2_MinSpd,SIGNAL(clicked(bool)),this,SLOT(slot_buttonSpdParaModify_clicked()));
    connect(ui->buttonKn2_AccSpd,SIGNAL(clicked(bool)),this,SLOT(slot_buttonSpdParaModify_clicked()));

    ui->frameWorkArea->setGeometry((FRAME_LEFT+25)*factoryX,(FRAME_TOP+58)*factoryY,455*factoryX,161*factoryY);
    ui->buttonX1->setGeometry(170*factoryX,60*factoryY,70*factoryX,38*factoryY);
    ui->buttonX2->setGeometry(10*factoryX,60*factoryY,70*factoryX,38*factoryY);
    ui->buttonY1->setGeometry(90*factoryX,10*factoryY,70*factoryX,38*factoryY);//y+
    ui->buttonY2->setGeometry(90*factoryX,120*factoryY,70*factoryX,38*factoryY);

    ui->frameKnifePressure->setGeometry((FRAME_LEFT+25)*factoryX,(FRAME_TOP+58)*factoryY,455*factoryX,161*factoryY);

    int btny = 70;
    int btnwidth = 80;
    int btnheight = 38;

    ui->label_LKPara->setGeometry(10*factoryX,20*factoryY,200*factoryX,btnheight*factoryY);
    ui->buttonLKParaModify->setGeometry(10*factoryX,btny*factoryY,btnwidth*factoryX,btnheight*factoryY);
    ui->buttonLKTest->setGeometry(110*factoryX,btny*factoryY,btnwidth*factoryX,btnheight*factoryY);

    ui->label_RKPara->setGeometry(260*factoryX,20*factoryY,200*factoryX,btnheight*factoryY);
    ui->buttonRKParaModify->setGeometry(260*factoryX,btny*factoryY,btnwidth*factoryX,btnheight*factoryY);
    ui->buttonRKTest->setGeometry(360*factoryX,btny*factoryY,btnwidth*factoryX,btnheight*factoryY);

    ui->buttonLKParaModify->setText(tr("U1 Modify"));//U1修改
    ui->buttonLKTest->setText(tr("U1 Test"));//U1测试
    ui->buttonRKParaModify->setText(tr("U2 Modify"));//U2修改
    ui->buttonRKTest->setText(tr("U2 Test"));//U2测试

    ui->buttonLKParaModify->setStyleSheet(textButtonStyle());
    ui->buttonLKTest->setStyleSheet(textButtonStyle());
    ui->buttonRKParaModify->setStyleSheet(textButtonStyle());
    ui->buttonRKTest->setStyleSheet(textButtonStyle());

    ui->label_LKPara->setText(tr("U1:"));//U1:
    ui->label_RKPara->setText(tr("U2:"));//U2:

    QFont  size = fontSize_L();
    QString pSize = QString::number(size.pointSize() + 5);
    QString style = "QLabel{border-radius:" + borderRadius() + "px;font-size:"+ pSize +"px;font-family:"+ "Microsoft YaHei"+";}";

    ui->label_LKPara->setStyleSheet(style);
    ui->label_RKPara->setStyleSheet(style);

    ui->frameFanArea->setGeometry((FRAME_LEFT+25)*factoryX,(FRAME_TOP+58)*factoryY,455*factoryX,161*factoryY);

    if(g_emMacType == MACHINE_FLYFLATCUTTING){
        ui->buttonFanOpen5->setGeometry(70*factoryX,25*factoryY,150*factoryX,80*factoryY);
        ui->buttonFanClose5->setGeometry(250*factoryX,25*factoryY,150*factoryX,80*factoryY);
        ui->buttonFanSet4->setVisible(false);
        ui->buttonFanSet2->setVisible(false);
        ui->buttonFanSet3->setVisible(false);
        ui->buttonFanSet1->setVisible(false);
        ui->buttonFanSet5->setVisible(false);
    }else{
    ui->buttonFanOpen5->setGeometry(270*factoryX,25*factoryY,80*factoryX,38*factoryY);
    ui->buttonFanClose5->setGeometry(370*factoryX,25*factoryY,80*factoryX,38*factoryY);

    int gapx = 80;
    int y = 25;
    int x = 60;
    ui->buttonFanSet4->setGeometry((x)*factoryX,y*factoryY,70*factoryX,38*factoryY);
    ui->buttonFanSet2->setGeometry((x+=gapx)*factoryX,y*factoryY,70*factoryX,38*factoryY);
    y+=45;
    x = 60;
    ui->buttonFanSet3->setGeometry(x*factoryX,y*factoryY,70*factoryX,38*factoryY);
    ui->buttonFanSet1->setGeometry((x+=gapx)*factoryX,y*factoryY,70*factoryX,38*factoryY);
    ui->buttonFanSet5->setGeometry((270)*factoryX,y*factoryY,80*factoryX,38*factoryY);
    }

    connect(ui->buttonFanOpen5,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    connect(ui->buttonFanClose5,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    connect(ui->buttonFanSet1,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    connect(ui->buttonFanSet2,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    connect(ui->buttonFanSet3,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    connect(ui->buttonFanSet4,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    connect(ui->buttonFanSet5,SIGNAL(clicked(bool)),this,SLOT(slot_FanArea_clicked()));
    ui->buttonFanOpen5->setText(tr("Ctrl Open"));//控制开启
    ui->buttonFanClose5->setText(tr("Ctrl Close"));//控制关闭
    ui->buttonFanClose5->setStyleSheet(textButtonStyle());
    ui->buttonFanOpen5->setStyleSheet(textButtonStyle());

    //主轴角度旋转
    ui->frameSpindleRotate->setGeometry(180*factoryX,178*factoryY,440*factoryX,161*factoryY);
    ui->labelSpindleAngle->setGeometry(150*factoryX,112*factoryY,120*factoryX,40*factoryY);
    ui->buttonSpindleAngleValue->setGeometry(275*factoryX,110*factoryY,78*factoryX,40*factoryY);
    ui->labelSpindleAngleUnit->setGeometry(364*factoryX,112*factoryY,91*factoryX,40*factoryY);

    //界面解密
    ui->frameHMIDecrypt->setGeometry(40*factoryX,78*factoryY,440*factoryX,161*factoryY);
    ui->labelNetworkCardID->setGeometry(10*factoryX,12*factoryY,110*factoryX,40*factoryY);
    ui->labelNetworkCardIDValue->setGeometry(130*factoryX,12*factoryY,200*factoryX,40*factoryY);
    ui->labelHMIPassword->setGeometry(10*factoryX,52*factoryY,110*factoryX,40*factoryY);
    ui->buttonHMIPassword->setGeometry(130*factoryX,50*factoryY,200*factoryX,40*factoryY);
    ui->labelDecryptInfo->setGeometry(10*factoryX,92*factoryY,110*factoryX,40*factoryY);
    ui->labelDecryptInfoValue->setGeometry(130*factoryX,92*factoryY,200*factoryX,40*factoryY);

    //修改一级密码
    ui->frameChangePassword->setGeometry(0*factoryX,78*factoryY,440*factoryX,161*factoryY);
    ui->labelNewPassword->setGeometry(0*factoryX,0*factoryY,140*factoryX,GLB_LBUT_HEIGHT*factoryY);
    ui->buttonNewPassword->setGeometry(180*factoryX,0*factoryY,200*factoryX,GLB_LBUT_HEIGHT*factoryY);
    ui->labelConfirmPassword->setGeometry(0*factoryX,52*factoryY,140*factoryX,GLB_LBUT_HEIGHT*factoryY);
    ui->buttonConfirmPassword->setGeometry(180*factoryX,52*factoryY,200*factoryX,GLB_LBUT_HEIGHT*factoryY);

    ui->frameThree->setGeometry(FRAME_LEFT*factoryX,
                              (FRAME_TOP+FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT)*factoryY,
                              FRAME_WIGHT*factoryX,
                              (GLB_LBUT_HEIGHT+GLB_EDGE_HEIGHT)*factoryY);
    ui->buttonRename->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*2)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonReplace->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*1)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonSkip->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);

    ui->frameDetecBtn->setGeometry(FRAME_LEFT*factoryX,
                              (FRAME_TOP+FRAME_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_HEIGHT)*factoryY,
                              FRAME_WIGHT*factoryX,
                              (GLB_LBUT_HEIGHT+GLB_EDGE_HEIGHT)*factoryY);
    ui->buttonDetectBegin->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*2)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonDetectEnd->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT-(GLB_BAS_WIGHT+GLB_LBUT_WIGHT)*1)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);
    ui->buttonDetectClose->setGeometry((FRAME_WIGHT-GLB_EDGE_WIGHT-GLB_LBUT_WIGHT)*factoryX,
                                  0*factoryY,
                                  GLB_LBUT_WIGHT*factoryX,
                                  GLB_LBUT_HEIGHT*factoryY);

}


//初始化窗体控件样式
void PromptDialog::initControlStyle()
{
    SetStyle setControlStyle;
    setControlStyle.setUiName(this->objectName());

    //设置控件图标
    //背景图
    this->setStyleSheet(titleTextColour());
    ui->frameBack->setStyleSheet(transparentStyle());
    ui->frameBack->setStyleSheet(setControlStyle.getStyleSheet(this->objectName()));
    ui->labelTitle->setStyleSheet(titleTextColour());
    ui->labelTitle->setFont(fontSize_M());
    ui->labelTitle->setAlignment(Qt::AlignLeft);
    ui->labelTitle->setAlignment(Qt::AlignVCenter);

    ui->frameProcess->setStyleSheet(transparentStyle());
    ui->progressBar->setFont(fontSize_M());

    ui->labelContent->setStyleSheet(warnTextColour());
    ui->labelContent->setFont(fontSize_M());
    ui->labelContent->setAlignment(Qt::AlignLeft);
    ui->labelContent->setAlignment(Qt::AlignVCenter);

    ui->labeBreakHead->setStyleSheet(warnTextColour());  // 断线机头  红色  字体加大  -rq
    ui->labeBreakHead->setFont(fontSize_M());
    ui->labeBreakHead->setAlignment(Qt::AlignLeft);
    ui->labeBreakHead->setAlignment(Qt::AlignVCenter);

    ui->labelContentInfo->setStyleSheet(warnTextColour());
    ui->labelContentInfo->setFont(fontSize_M());
    ui->labelContentInfo->setAlignment(Qt::AlignLeft);
    ui->labelContentInfo->setAlignment(Qt::AlignVCenter);

    ui->labelContentProcess->setStyleSheet(numButtonStyle());
    ui->labelContentProcess->setFont(fontSize_M());
    ui->labelContentProcess->setAlignment(Qt::AlignLeft);
    ui->labelContentProcess->setAlignment(Qt::AlignVCenter);

    ui->labelContentWarrant->setStyleSheet(warnTextColour());
    ui->labelContentWarrant->setFont(fontSize_M());
    ui->labelContentWarrant->setAlignment(Qt::AlignLeft);
    ui->labelContentWarrant->setAlignment(Qt::AlignVCenter);

    ui->frameTwo->setStyleSheet(transparentStyle());

    ui->buttonOk->setStyleSheet(confirmIconStyle());
    ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet("buttonOk"),12);
    ui->buttonCancel->setStyleSheet(confirmIconStyle());
    ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet("buttonCancel"),12);

    ui->buttonForward->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonForward->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonForward->objectName()));
    ui->buttonReverse->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonReverse->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonReverse->objectName()));

    ui->frameThree->setStyleSheet(transparentStyle());
    ui->buttonRename->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonReplace->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonSkip->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonRename->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRename->objectName()));
    ui->buttonReplace->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonReplace->objectName()));
    ui->buttonSkip->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonSkip->objectName()));

    ui->frameDetecBtn->setStyleSheet(transparentStyle());
    ui->buttonDetectBegin->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonDetectBegin->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDetectBegin->objectName()));
    ui->buttonDetectEnd->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonDetectEnd->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonDetectEnd->objectName()));
    ui->buttonDetectClose->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonDetectClose->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"));

    ui->frameProcessBtn->setStyleSheet(transparentStyle());
    ui->buttonRestart->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonRestart->setTopImage(setControlStyle.getTopStyleSheet(ui->buttonRestart->objectName()));
    ui->buttonUpdataCancel->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonUpdataCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"));

    //设置可工作区域
    ui->frameWorkArea->setStyleSheet(transparentStyle());
    ui->buttonX1->setFont(fontSize_M());
    ui->buttonX2->setFont(fontSize_M());
    ui->buttonY1->setFont(fontSize_M());
    ui->buttonY2->setFont(fontSize_M());

    ui->frameKnifePressure->setStyleSheet(transparentStyle());

    ui->frameFanArea->setStyleSheet(transparentStyle());
    ui->frameSpdSelect->setStyleSheet(transparentStyle());

    ui->buttonKn1_MaxSpd->setStyleSheet(flippingStyle());
    ui->buttonKn1_MinSpd->setStyleSheet(flippingStyle());
    ui->buttonKn1_AccSpd->setStyleSheet(flippingStyle());

    ui->buttonKn2_MaxSpd->setStyleSheet(flippingStyle());
    ui->buttonKn2_MinSpd->setStyleSheet(flippingStyle());
    ui->buttonKn2_AccSpd->setStyleSheet(flippingStyle());

    //主轴角度旋转
    ui->frameSpindleRotate->setStyleSheet(transparentStyle());
    ui->labelSpindleAngle->setStyleSheet(titleTextColour());
    ui->labelSpindleAngle->setFont(fontSize_M());
    ui->labelSpindleAngleUnit->setStyleSheet(titleTextColour());
    ui->labelSpindleAngleUnit->setFont(fontSize_M());
    ui->buttonSpindleAngleValue->setFont(fontSize_M());

    //界面解密
    ui->frameHMIDecrypt->setStyleSheet(transparentStyle());
    ui->labelNetworkCardID->setStyleSheet(titleTextColour());
    ui->labelNetworkCardID->setFont(fontSize_M());
    ui->labelNetworkCardIDValue->setStyleSheet(titleTextColour());
    ui->labelNetworkCardIDValue->setFont(fontSize_M());
    ui->labelHMIPassword->setStyleSheet(titleTextColour());
    ui->labelHMIPassword->setFont(fontSize_M());
    ui->buttonHMIPassword->setFont(fontSize_M());
    ui->labelDecryptInfo->setStyleSheet(titleTextColour());
    ui->labelDecryptInfo->setFont(fontSize_M());
    ui->labelDecryptInfoValue->setStyleSheet(titleTextColour());
    ui->labelDecryptInfoValue->setFont(fontSize_M());

    //修改一级密码
    ui->frameChangePassword->setStyleSheet(transparentStyle());
    ui->labelNewPassword->setStyleSheet(titleTextColour());
    ui->labelNewPassword->setFont(fontSize_M());
    ui->labelConfirmPassword->setStyleSheet(titleTextColour());
    ui->labelConfirmPassword->setFont(fontSize_M());
    ui->buttonNewPassword->setFont(fontSize_M());
    ui->buttonConfirmPassword->setFont(fontSize_M());

    ui->frameWarrantBtn->setStyleSheet(transparentStyle());
    ui->buttonWarrant->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonWarrant->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()+"_1"));
    ui->buttonWarrantCancel->setBottomImage(setControlStyle.getSharedBottomStyleSheet("frameBtn"));
    ui->buttonWarrantCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()+"_1"));
}

///
/// \brief 刷新显示
///
void PromptDialog::refreshMcPara()
{
    if(g_emMacType == MACHINE_DRAWING)
    {
        ParaStruct mcPara = g_pMachine->getMcPara();
        //笔压测试
        int LkHeight = 0;
        double Lkdouble = 0;

        LkHeight = mcPara.buf[83];
        Lkdouble = LkHeight;

        ui->buttonLKParaModify->setText(tr("P1 Modify"));//U1修改
        ui->buttonLKTest->setText(tr("P1 Test"));//U1测试
        ui->label_LKPara->setText(tr("P1:") + QString::number(Lkdouble/100,'f',2));//P1:

        ui->buttonRKTest->hide();
        ui->buttonRKParaModify->hide();
        ui->label_RKPara->hide();
    }
    else
    {
        ParaStruct mcPara = g_pMachine->getMcPara();
        //刀压测试
        int LkHeight = 0;
        int RkHeight = 0;
        double Lkdouble = 0;
        double Rkdouble = 0;

    // 刀座1安装刀类型选择 0,无 1,圆刀 2,震刀 3,铣刀 4,偏心刀1 5,偏心刀2 6,画笔 7,尖刀 8,钻孔 9,压轮
    if (mcPara.buf[10] == 1)
    {//1,圆刀
        LkHeight = mcPara.buf[87];
    }
    else if (mcPara.buf[10] == 2)
    {//2,震刀
        LkHeight = mcPara.buf[90];
    }
    else if (mcPara.buf[10] == 3)
    {//3,铣刀
        LkHeight = mcPara.buf[93];
    }
    else if (mcPara.buf[10] == 4)
    {//4,偏心刀1
        LkHeight = mcPara.buf[96];
    }
    else if (mcPara.buf[10] == 5)
    {//5,偏心刀2
        LkHeight = mcPara.buf[98];
    }
    else if (mcPara.buf[10] == 7)
    {//7,尖刀
        LkHeight = mcPara.buf[105];
    }
    else if (mcPara.buf[10] == 8)
    {//8,钻孔
        LkHeight = mcPara.buf[103];
    }
    else if (mcPara.buf[10] == 9)
    {//9,压轮
        LkHeight = mcPara.buf[100];
    }
    else
    {//
        LkHeight = 0;
    }

    // 刀座2安装刀类型选择 0,无 1,圆刀 2,震刀 3,铣刀 4,偏心刀1 5,偏心刀2 6,画笔 7,尖刀 8,钻孔 9,压轮
    if (mcPara.buf[11] == 1)
    {//1,圆刀
        RkHeight = mcPara.buf[87];
    }
    else if (mcPara.buf[11] == 2)
    {//2,震刀
        RkHeight = mcPara.buf[90];
    }
    else if (mcPara.buf[11] == 3)
    {//3,铣刀
        RkHeight = mcPara.buf[93];
    }
    else if (mcPara.buf[11] == 4)
    {//4,偏心刀1
        RkHeight = mcPara.buf[96];
    }
    else if (mcPara.buf[11] == 5)
    {//5,偏心刀2
        RkHeight = mcPara.buf[98];
    }
    else if (mcPara.buf[11] == 7)
    {//7,尖刀
        RkHeight = mcPara.buf[105];
    }
    else if (mcPara.buf[11] == 8)
    {//8,钻孔
        RkHeight = mcPara.buf[103];
    }
    else if (mcPara.buf[11] == 9)
    {//9,压轮
        RkHeight = mcPara.buf[100];
    }
    else
    {//
        RkHeight = 0;
    }

    Lkdouble = LkHeight;
    Rkdouble = RkHeight;

        ui->label_LKPara->setText(tr("U1:") + QString::number(Lkdouble/100,'f',2));//U1:
        ui->label_RKPara->setText(tr("U2:") + QString::number(Rkdouble/100,'f',2));//U2:
    }
}

using namespace std;
void PromptDialog::refreshWkPara()
{
    ParaStruct wkPara = g_pMachine->getWkPara();
    //单独吸附区域
    bitset<32> intbit(wkPara.buf[83]);

    btnDisplay(ui->buttonFanSet1,intbit.test(0),"1");
    btnDisplay(ui->buttonFanSet2,intbit.test(1),"2");
    btnDisplay(ui->buttonFanSet3,intbit.test(2),"3");
    btnDisplay(ui->buttonFanSet4,intbit.test(3),"4");

    //手动自动
    bitset<32> intbit2(wkPara.buf[102]);
    if(intbit2.test(0))
        ui->buttonFanSet5->setText(tr("Auto"));//自动
    else
        ui->buttonFanSet5->setText(tr("Manual"));//手动
}

void PromptDialog::btnDisplay(MyButton *btn, bool isTrue,QString str)
{
    if(isTrue)
    {
        btn->setText(str + tr("Opened"));//已开启
        btn->setStyleSheet(flippingStyle());
    }
    else
    {
        btn->setText(str + tr("Closed"));//已关闭
        btn->setStyleSheet(confirmIconStyle());
    }
}

//设置标题
void PromptDialog::setTitleStr(QString str)
{
    ui->labelTitle->setText(str);
}

//设置断线机头字体颜色
void PromptDialog::setStrColor(QString str)
{
    ui->frameProcess->hide();
    ui->labelContentInfo->setText("");
    ui->labelContentInfo->hide();
    ui->labelContentWarrant->setText("");
    ui->labelContentWarrant->hide();
    ui->labelContent->setText("");
    ui->labelContent->hide();
    ui->labeBreakHead->setText(str);
    ui->labeBreakHead->show();
}

//设置显示内容
void PromptDialog::setContentStr(QString str)
{
    ui->frameProcess->hide();
    ui->labelContentInfo->setText("");
    ui->labelContentInfo->hide();
    ui->labeBreakHead->setText("");//断线机头显示
    ui->labeBreakHead->hide();
    ui->labelContentWarrant->setText("");
    ui->labelContentWarrant->hide();
    ui->labelContent->setText(str);
    ui->labelContent->show();
}

void PromptDialog::setContentProcessStr(QString str)
{
    ui->frameProcess->show();
    ui->labelContentInfo->setText("");
    ui->labelContentInfo->hide();
    ui->labeBreakHead->setText("");//断线机头显示
    ui->labeBreakHead->hide();
    ui->labelContent->setText("");
    ui->labelContent->hide();
    ui->labelContentWarrant->setText("");
    ui->labelContentWarrant->hide();
    ui->labelContentProcess->show();
    ui->labelContentProcess->setText(str);
}

void PromptDialog::setContentInfoShow()
{
    ui->labelContent->hide();
    ui->labeBreakHead->hide();
    ui->frameProcess->hide();
    ui->labelContentWarrant->hide();
    ui->labelContentInfo->show();
    ui->labelContentInfo->raise();
}

void PromptDialog::setContentWarrantShow()
{
    ui->labelContent->hide();
    ui->labeBreakHead->hide();
    ui->frameProcess->hide();
    ui->labelContentInfo->hide();
    ui->labelContentWarrant->show();
}

void PromptDialog::setContentHMIDecryptShow(QString id)
{
    //将id中的冒号去掉
    QStringList strlist = id.split(":", QString::SkipEmptyParts);
    QString nId;
    nId.clear();
    for(int i = 0; i < strlist.size(); i++)
    {
        nId += strlist[i];
    }
    ui->labelNetworkCardIDValue->setText(nId);
    ui->buttonHMIPassword->setText("");

    QDir apppath(qApp->applicationDirPath());
    QString HMIDecryptConfigfile;
    HMIDecryptConfigfile = apppath.path() + apppath.separator() + "HMIDecryptConfig.ini";
    QSettings iniSetting(HMIDecryptConfigfile, QSettings::IniFormat);
    int decryptFlag = iniSetting.value("HMIDecrypt/ifdecrypt").toInt();
    QFile iniFile(HMIDecryptConfigfile);
    if(decryptFlag != 0 || !iniFile.exists())//等于1或者配置文件不存在
    {
        ui->labelDecryptInfoValue->setText("HMI decrypted");//界面已解密
    }
    else
    {
        ui->labelDecryptInfoValue->setText("HMI unresolved");//界面未解密
    }

    ui->buttonOk->setEnabled(false);
}

void PromptDialog::setContentChangePasswordShow()//修改一级用户密码内容显示
{
    ui->buttonNewPassword->setText("");
    ui->buttonConfirmPassword->setText("");
    ui->buttonOk->setEnabled(false);
}

void PromptDialog::setValue(int progress)
{
    ui->progressBar->setValue(progress);
}

void PromptDialog::setButtonUCancelStr(QString str)
{
    ui->buttonUpdataCancel->setText(str);
}

void PromptDialog::setRange(int minimum, int maximum)
{
    ui->progressBar->setRange(minimum,maximum);
}

QString PromptDialog::getNetworkCardID()
{
    return ui->labelNetworkCardIDValue->text();
}

QString PromptDialog::getInputPassword()
{
    return ui->buttonHMIPassword->text();
}

void PromptDialog::slotMCInfoChange()
{
    QString strInfo;
    MCInfo info;
    char softwareVerStr[32+1];
    char softwareTimeStr[32+1];

    info = g_pMachine->getMcInfo();
    memcpy(softwareVerStr, info.softwareVerStr, 32);
    memcpy(softwareTimeStr, info.buildInfoStr, 32);
    softwareVerStr[32] = 0;
    softwareTimeStr[32] = 0;
    QString strBoardVer;
    strBoardVer.sprintf("%s", softwareVerStr);
    strInfo += tr("Board") + " " +  strBoardVer + "\n";
    QString softwareBulid;
    softwareBulid.sprintf("%s", softwareTimeStr);

    QString verInfo = "\n" + strInfo + "\r\n" + tr("Build Time:") + softwareBulid.right(softwareBulid.size() - 6);//编译时间：
    ui->labelContentInfo->setText(verInfo);

    //连接多块主板也是从g_pMachine(第一块)获取软件授权信息
    MCStatus mcStatus;
    mcStatus = g_pMachine->getMcStatus();

    MCInfo infoID;
    infoID = g_pMachine->getMcInfo();

    QString IDStr(infoID.boardId);
    if(IDStr.indexOf(":") != -1)
    {
        QStringList list = IDStr.split(":");
        IDStr = list.at(1);
    }

    QString passwordStr(infoID.installment);
    if(passwordStr.indexOf(":") != -1)
    {
        QStringList list = passwordStr.split(":");
        passwordStr = list.at(1);
    }

    int time = mcStatus.workableTimer;//只在上电的时候读取
    QString timeStr;
    if( time > TIMELIMITMIN && time < TIMELIMITMAX)
    {
        timeStr = (tr("Unlimited time"));   // 无时间限制
    }
    if(time <= 0)
    {
        timeStr = (tr("Time has run out")); // 时间已用完
    }
    if(time > 0 && time < TIMELIMITMIN)
    {
        QString strDay;
        QString strHour;
        QString strSec;

        strDay  = QString::number(time/(60 *24) , 10);
        strHour = QString::number((time%(60 *24))/60 , 10) ;
        strSec  = QString::number(time%60 , 10);

        timeStr = strDay + " " + tr("Day") + " " + strHour + " " + tr("Hour")  + " " +  strSec  + " " + tr("Minutes") ;  // 天   小时   分钟
    }

    QString strBoardInfo;
    strBoardInfo = QString(tr("ID: %1\n")).arg(IDStr);
    strBoardInfo += QString(tr("Password: %1\n")).arg(passwordStr);
    strBoardInfo += QString(tr("Time: %1")).arg(timeStr);
    ui->labelContentWarrant->setText(strBoardInfo);
}

void PromptDialog::on_buttonOk_clicked()
{
    if(m_funType == BTN_SPINDLE_ROTATE)
    {
        emit siSpindleRotate(m_spindleAngle);
        done(0);
    }
    else if(m_funType == BTN_ROTATE_ROTATE)
    {
        emit siRotateRotate(m_spindleAngle);
        done(0);
    }
    else if(m_funType == BTN_AUTOMATIC_PULLMA)
    {
        emit siAutoPull(m_length);
        done(0);
    }
    else if(m_funType == BTN_SPINDLE_GRANDE)
    {
        emit siSpindleTime(m_time,m_speed);
        done(0);
    }
    else
    {
        done(1);
    }
}

void PromptDialog::on_buttonCancel_clicked()
{
    done(0);
}

void PromptDialog::on_buttonRename_clicked()
{
    done(1);
}

void PromptDialog::on_buttonReplace_clicked()
{
    done(2);
}

void PromptDialog::on_buttonSkip_clicked()
{
    done(0);
}

//重启
void PromptDialog::on_buttonRestart_clicked()
{
#ifdef Q_OS_WIN
    qApp->exit();
#endif

#ifdef Q_OS_LINUX
    system("reboot");
#endif
}

//升级中断
void PromptDialog::on_buttonUpdataCancel_clicked()
{
    emit(siUpdataCancel());
    done(0);
}

void PromptDialog::on_buttonWarrant_clicked()
{
    //输入框
    WordsInputDialog wordInputDlg;
    wordInputDlg.clean();
    wordInputDlg.setTitleStr(tr("Warrant"));
    wordInputDlg.setOldWordsStr("");
    if(wordInputDlg.exec() == 1)
    {
        QString textStr = wordInputDlg.getInputStr();
        //连接多块主板也是从g_pMachine(第一块)获取软件授权信息，所以解锁也是通过第一块主板
        g_pMachine->setMacKey(( unsigned char * ) textStr.toLatin1().data() ,textStr.toLatin1().size());
        done(1);
    }
}

void PromptDialog::on_buttonWarrantCancel_clicked()
{
    done(0);
}

//开始检测
void PromptDialog::on_buttonDetectBegin_clicked()
{
    if(m_funType == BTN_BOTTOM)//等于底线检测
    {
        return;
    }
    if(m_funType == BTN_FACE)//等于面线检测
    {
        return;
    }
}

//停止检测
void PromptDialog::on_buttonDetectEnd_clicked()
{
    if(g_pMachine!= NULL)
    {
        g_pMachine->exitDetectTest();
    }
}

//关闭检测窗体
void PromptDialog::on_buttonDetectClose_clicked()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->exitDetectTest();
    }
    done(0);
}

//界面解密ID号输入按钮
void PromptDialog::on_buttonHMIPassword_clicked()
{
    //输入框
    WordsInputDialog wordInputDlg;
    wordInputDlg.clean();
    wordInputDlg.setTitleStr(tr("HMI decrypt"));
    wordInputDlg.setOldWordsStr("");
    if(wordInputDlg.exec() == 1)
    {
        QString textStr = wordInputDlg.getInputStr();
        ui->buttonHMIPassword->setText(textStr);
        if(textStr.length() > 0)
        {
            ui->buttonOk->setEnabled(true);
        }
    }
}

void PromptDialog::on_buttonSpindleAngleValue_clicked()
{
    if(m_funType == BTN_AUTOMATIC_PULLMA)
    {
        int rslt;
        NumerInputDialog ndlg(this);
        ndlg.setTitleStr(tr("autoPull"));//自动拉料
        ndlg.setUnitStr(tr("mm"));
        ndlg.setValueAndRange(ui->buttonSpindleAngleValue->text().toInt(), 0, 36000, 0);
        rslt = ndlg.exec();

        if (rslt == 1)//输入弹窗点击了确认
        {
            s32 val = ndlg.getValue();
            m_length = val;
            float angle = m_length;
            QString angleStr;
            angleStr.sprintf("%.0f",angle);
            ui->buttonSpindleAngleValue->setText(angleStr);
        }
    }
    else if(m_funType == BTN_SPINDLE_GRANDE)
    {
        //时间
        int rslt;
        NumerInputDialog ndlg(this);
        ndlg.setTitleStr(tr("Research vehicle time"));//研车时间
        ndlg.setUnitStr(tr("s"));
        ndlg.setValueAndRange(ui->buttonSpindleAngleValue->text().toInt(), 0, 36000, 0);
        rslt = ndlg.exec();

        if (rslt == 1)//输入弹窗点击了确认
        {
            s32 val = ndlg.getValue();
            m_time = val;
            float time = m_time;
            QString timeStr;
            timeStr.sprintf("%.0f",time);
            ui->buttonSpindleAngleValue->setText(timeStr);
        }

//        //速度
//        int rosh;
//        NumerInputDialog ndsh(this);
//        ndsh.setTitleStr(tr("Research vehicle speed"));//研车速度
//        ndsh.setUnitStr(tr("s"));
//        ndsh.setValueAndRange(ui->buttonSpindleAngleValue->text().toInt(), 0, 36000, 0);
//        rosh = ndsh.exec();

    }
    else
    {
        QTextCodec *cod = QTextCodec::codecForLocale();
        int rslt;
        NumerInputDialog ndlg(this);
        if(m_funType == BTN_SPINDLE_ROTATE)
        {
            ndlg.setTitleStr(tr("Spindle angle rotation"));//主轴角度旋转
        }
        else if(m_funType == BTN_ROTATE_ROTATE)
        {
            ndlg.setTitleStr(tr("Rotation angle rotation"));//旋转角度旋转
        }
        else if(m_funType == BTN_SPINDLE_GRANDE)
        {

        }
        else
        {
            ndlg.setTitleStr(tr("Spindle angle rotation"));//主轴角度旋转
        }
        ndlg.setUnitStr(cod->toUnicode("°"));
        ndlg.setValueAndRange(ui->buttonSpindleAngleValue->text().toInt()*100, 0, 36000, 2);
        rslt = ndlg.exec();

        if (rslt == 1)//输入弹窗点击了确认
        {
            s32 val = ndlg.getValue();
            m_spindleAngle = val;
            float angle = m_spindleAngle*0.01;
            QString angleStr;
            angleStr.sprintf("%.2f",angle);
            ui->buttonSpindleAngleValue->setText(angleStr);
        }
    }

}

//修改一级密码:新密码输入按钮
void PromptDialog::on_buttonNewPassword_clicked()
{
    //密码输入框
    PassWordDialog passWordDlg;
    passWordDlg.setTitleStr(tr("New Password input"));//设置新密码输入的标题
    if(passWordDlg.exec() == 1)//确认
    {
        m_newPassword = passWordDlg.getInputStr();//获取输入框里的密码
        QString showStr("");
        for (int var = 0; var < m_newPassword.size(); var++)
        {
            showStr = showStr + "*";
        }
        ui->buttonNewPassword->setText(showStr);//新密码框里显示获取的密码
    }
}
//修改一级密码:确认新密码输入按钮
void PromptDialog::on_buttonConfirmPassword_clicked()
{
    //密码输入框
    PassWordDialog passWordDlg;
    passWordDlg.setTitleStr(tr("Confirm Password input"));//设置确认密码输入的标题
    if(passWordDlg.exec() == 1)//确认
    {
        m_confirmPassword = passWordDlg.getInputStr();//获取输入框里的密码
        QString showStr("");
        for (int var = 0; var < m_confirmPassword.size(); var++)
        {
            showStr = showStr + "*";
        }
        ui->buttonConfirmPassword->setText(showStr);//确认密码框里显示获取的密码
        if(m_confirmPassword.length() > 0 )
        {
            ui->buttonOk->setEnabled(true);
        }
    }

}

//主轴正转
void PromptDialog::on_buttonForward_pressed()
{
    emit siSpindleAction(MT_MOVE_DIR_POSI);
}

//主轴正转停止
void PromptDialog::on_buttonForward_released()
{
    emit siSpindleAction(MT_MOVE_DIR_STOP);
}

//主轴反转
void PromptDialog::on_buttonReverse_pressed()
{
    emit siSpindleAction(MT_MOVE_DIR_NEGA);
}

//主轴反转停止
void PromptDialog::on_buttonReverse_released()
{
    emit siSpindleAction(MT_MOVE_DIR_STOP);
}

void PromptDialog::on_buttonX1_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_RIGHT, 2);//速度等级默认是2
    }
}

void PromptDialog::on_buttonX1_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_RIGHT, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 2;
}

void PromptDialog::on_buttonX2_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_LEFT, 2);
    }
}

void PromptDialog::on_buttonX2_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_LEFT, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 1;
}

void PromptDialog::on_buttonY1_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_FRONT, 2);
    }
}
//Y+
void PromptDialog::on_buttonY1_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_FRONT, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 4;
}

void PromptDialog::on_buttonY2_pressed()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(XY_MOVE_BACK, 2);
    }
}
//Y-
void PromptDialog::on_buttonY2_released()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->motoMove(XY_MOVE_BACK, MT_MOVE_DIR_STOP, 0);
    }
    m_area = 3;
}

void PromptDialog::on_buttonLKTest_clicked()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(KNIFE_U1_TEST);
    }
}

void PromptDialog::on_buttonRKTest_clicked()
{
    if(g_pMachine != NULL)
    {
        g_pMachine->manualAction(KNIFE_U2_TEST);
    }
}

void PromptDialog::on_buttonLKParaModify_clicked()
{
    if(g_emMacType == MACHINE_DRAWING)
    {
        slot_Modify_McPara_int(83,tr("Brush processing descent height"),"mm",10000,-100,2);
    }
    else
    {
        ParaStruct mcPara = g_pMachine->getMcPara();
        // 刀座1安装刀类型选择 0,无 1,圆刀 2,震刀 3,铣刀 4,偏心刀1 5,偏心刀2 6,画笔 7,尖刀 8,钻孔 9,压轮
        if (mcPara.buf[10] == 1)
        {//1,圆刀
            slot_Modify_McPara_int(87,tr("Height of tool drop during circular cutting"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 2)
        {//2,震刀
            slot_Modify_McPara_int(90,tr("Height of tool drop Shock knife"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 3)
        {//3,铣刀
            slot_Modify_McPara_int(93,tr("Height of tool drop milling cutter"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 4)
        {//4,偏心刀1
            slot_Modify_McPara_int(96,tr("Eccentric tool 1 machining tool drop height"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 5)
        {//5,偏心刀2
            slot_Modify_McPara_int(98,tr("Eccentric tool 2 machining tool drop height"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 7)
        {//7,尖刀
            slot_Modify_McPara_int(105,tr("Knife and pen drop height"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 8)
        {//8,钻孔
            slot_Modify_McPara_int(103,tr("Cutting height of drilling tool during machining"),"mm",10000,-100,2);
        }
        else if (mcPara.buf[10] == 9)
        {//9,压轮
            slot_Modify_McPara_int(100,tr("Height of tool drop during wheel pressing"),"mm",10000,-100,2);
        }
        else
        {//
        }
    }

    refreshMcPara();
}

void PromptDialog::on_buttonRKParaModify_clicked()
{
    ParaStruct mcPara = g_pMachine->getMcPara();
    // 刀座2安装刀类型选择 0,无 1,圆刀 2,震刀 3,铣刀 4,偏心刀1 5,偏心刀2 6,画笔 7,尖刀 8,钻孔 9,压轮
    if (mcPara.buf[11] == 1)
    {//1,圆刀
        slot_Modify_McPara_int(87,tr("Height of tool drop during circular cutting"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 2)
    {//2,震刀
        slot_Modify_McPara_int(90,tr("Height of tool drop Shock knife"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 3)
    {//3,铣刀
        slot_Modify_McPara_int(93,tr("Height of tool drop milling cutter"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 4)
    {//4,偏心刀1
        slot_Modify_McPara_int(96,tr("Eccentric tool 1 machining tool drop height"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 5)
    {//5,偏心刀2
        slot_Modify_McPara_int(98,tr("Eccentric tool 2 machining tool drop height"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 7)
    {//7,尖刀
        slot_Modify_McPara_int(105,tr("Knife and pen drop height"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 8)
    {//8,钻孔
        slot_Modify_McPara_int(103,tr("Cutting height of drilling tool during machining"),"mm",10000,-100,2);
    }
    else if (mcPara.buf[11] == 9)
    {//9,压轮
        slot_Modify_McPara_int(100,tr("Height of tool drop during wheel pressing"),"mm",10000,-100,2);
    }
    else
    {//
    }
    refreshMcPara();
}

///
/// \brief 速度选择界面点击修改速度按钮
/// 注意更新速度的范围
///
void PromptDialog::slot_buttonSpdParaModify_clicked()
{
    MyButton *p = (MyButton*)this->sender();
    QString btnName = p->objectName();
    int model = g_pSettings->readFromIniFile("FlatPanelSpd/Model").toInt();

    //不同模式 读数据 配置文件
    if(btnName.contains("buttonKn1_MinSpd")){
        if(g_emMacType == MACHINE_FLATCUTTINGMAC)
        {
            ///1修改参数发送下位机
            //偏心刀1最小切割速度
            int val = slot_Modify_McPara_int(166,tr("Minimum cutting speed of Eccentric knife1"),"mm/s", 100, 1, 0);

            ///2修改按钮显示
            p->setText(m_speedStr2+QString::number(val));//刀1最小
            ///3修改配置文件
            g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn1Min",QVariant(val));
        }
        else if(g_emMacType == MACHINE_DRAWING)
        {
            int val = slot_Modify_McPara_int(150,tr("The minimum drawing speed of the brush"),"mm/s", 100, 1, 0);
            p->setText(m_speedStr2+QString::number(val));//最小
            g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn1Min",QVariant(val));
        }
    }
    else if(btnName.contains("buttonKn1_MaxSpd")){
        if(g_emMacType == MACHINE_FLATCUTTINGMAC)
        {
            //偏心刀1最大切割速度
            int val =  slot_Modify_McPara_int(167,tr("Maximum cutting speed of Eccentric knife1"),"mm/s", 800, 1, 0);
            p->setText(m_speedStr1+QString::number(val));//刀1最大
            g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn1Max",QVariant(val));
        }
        else if(g_emMacType == MACHINE_DRAWING)
        {
            int val =  slot_Modify_McPara_int(151,tr("Maximum painting speed of the brush"),"mm/s", 1500, 1, 0);
            p->setText(m_speedStr1+QString::number(val));//最大
            g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn1Max",QVariant(val));
        }
    }
    else if(btnName.contains("buttonKn1_AccSpd")){
        if(g_emMacType == MACHINE_FLATCUTTINGMAC)
        {
            //偏心刀1切割加速度
            int val =  slot_Modify_McPara_int(168,tr("Eccentric knife 1 cutting acceleration"),"mm/s2", 5000, 1, 0);
            p->setText(tr("Kn1Acc:")+QString::number(val));//刀1加速
            g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn1Acc",QVariant(val));
        }
        else if(g_emMacType == MACHINE_DRAWING)
        {
            //偏心刀1切割加速度
            int val =  slot_Modify_McPara_int(152,tr("Brush painting acceleration"),"mm/s2", 5000, 1, 0);
            p->setText(m_speedStr3+QString::number(val));//加速
            g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn1Acc",QVariant(val));
        }
    }
    else if(btnName.contains("buttonKn2_MinSpd")){
        //偏心刀2最小切割速度
        int val =  slot_Modify_McPara_int(170,tr("Minimum cutting speed of Eccentric knife2"),"mm/s", 100, 1, 0);
        p->setText(tr("Kn2Min:")+QString::number(val));//刀2最小
        g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn2Min",QVariant(val));
    }
    else if(btnName.contains("buttonKn2_MaxSpd")){
        //偏心刀2最大切割速度
        int val =  slot_Modify_McPara_int(171,tr("Maximum cutting speed of Eccentric knife2"),"mm/s", 800, 1, 0);
        p->setText(tr("Kn2Max:")+QString::number(val));//刀2最大
        g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn2Max",QVariant(val));
    }
    else if(btnName.contains("buttonKn2_AccSpd")){
        //偏心刀2切割加速度
        int val =  slot_Modify_McPara_int(172,tr("Eccentric knife 2 cutting acceleration"),"mm/s2", 5000, 1, 0);
        p->setText(tr("Kn2Acc:")+QString::number(val));//刀2加速
        g_pSettings->writeToIniFile("FlatPanelSpd/M"+ QString::number(model)+"Kn2Acc",QVariant(val));
    }

}

///
/// \brief 修改int类型的机器参数
///
int PromptDialog::slot_Modify_McPara_int(int index, QString descStr, QString unitStr, int Max, int Min, int afterpoint)
{
    int val = g_pMachine->getMcPara().buf[index];
    NumerInputDialog ndlg(this);
    ndlg.setTitleStr(descStr);
    ndlg.setUnitStr(unitStr);
    ndlg.setValueAndRange(val, Min, Max, afterpoint);
    int rslt = ndlg.exec();
    if (rslt == 1)//点了确认按钮
    {
        val = ndlg.getValue();
        ParaStruct para = g_pMachine->getMcPara();
        para.buf[index] = val;
        g_pMachine->setMcPara(&para);//发送下位机
    }
    return val;
}

void PromptDialog::slot_FanArea_clicked()
{
    MyButton *p = (MyButton*)this->sender();
    QString btnName = p->objectName();
    qDebug()<<btnName;
    if(btnName.contains("FanOpen5"))
    {
        g_pMachine->outputCtrl(OT_MAINADSORB, UP_OPEN_ON, 0);
    }
    else if(btnName.contains("FanClose5"))
    {
        g_pMachine->outputCtrl(OT_MAINADSORB, DOWN_CLOSE_OFF, 0);
    }
    else if(btnName.contains("FanSet"))
    {
        int index = btnName.right(1).toInt();
        ParaStruct wkPara = g_pMachine->getWkPara();
        bitset<32> intbit(wkPara.buf[83]);//吸附区域 83 bit 0-3
        if(index == 1)
        {
            bool val = intbit.test(0); //按位修改
            intbit.set(0, !val);
            wkPara.buf[83] = intbit.to_ulong();
        }
        else if(index == 2)
        {
            bool val = intbit.test(1);
            intbit.set(1, !val);
            wkPara.buf[83] = intbit.to_ulong();
        }
        else if(index == 3)
        {
            bool val = intbit.test(2);
            intbit.set(2, !val);
            wkPara.buf[83] = intbit.to_ulong();
        }
        else if(index == 4)
        {
            bool val = intbit.test(3);
            intbit.set(3, !val);
            wkPara.buf[83] = intbit.to_ulong();
        }
        else if(index == 5)
        {//风机吸附开关 102 bit0
            bitset<32> intAllBit(wkPara.buf[102]);
            bool val = intAllBit.test(0);
            intAllBit.set(0, !val);
            wkPara.buf[102] = intAllBit.to_ulong();
        }
        g_pMachine->setWkPara(&wkPara);
        refreshWkPara();
    }

}

void PromptDialog::slot_SpdSelect_clicked()
{
    MyButton *p = (MyButton*)this->sender();
    QString btnName = p->objectName();
    int kn1Min = 0, kn1Max = 0, kn1Acc = 0, kn2Min = 0 , kn2Max = 0, kn2Acc = 0;

    for(int i = 1;i < 6; i++){
        if(btnName.contains("radioButtonSpd_"+QString::number(i))){
            g_pSettings->writeToIniFile("FlatPanelSpd/Model",QVariant(i));
            kn1Min = g_pSettings->readFromIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn1Min").toInt();
            kn1Max = g_pSettings->readFromIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn1Max").toInt();
            kn1Acc = g_pSettings->readFromIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn1Acc").toInt();
            kn2Min = g_pSettings->readFromIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn2Min").toInt();
            kn2Max = g_pSettings->readFromIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn2Max").toInt();
            kn2Acc = g_pSettings->readFromIniFile("FlatPanelSpd/M"+ QString::number(i)+"Kn2Acc").toInt();
        }
    }

    //验证数据范围是否正确
    if(kn1Min<1 || kn1Min>100)
        kn1Min = 10;
    if(kn2Min<1 || kn2Min>100)
        kn2Min = 10;

    if(g_emMacType == MACHINE_DRAWING)
    {
        if(kn1Max<1 || kn1Max>1500)
            kn1Max = 1500;
        if(kn2Max<1 || kn2Max>1500)
            kn2Max = 1500;
    }
    else if(g_emMacType == MACHINE_FLATCUTTINGMAC)
    {
        if(kn1Max<1 || kn1Max>800)
            kn1Max = 800;
        if(kn2Max<1 || kn2Max>800)
            kn2Max = 800;
    }

    if(kn1Acc<1 || kn1Acc>5000)
        kn1Acc = 500;
    if(kn2Acc<1 || kn2Acc>5000)
        kn2Acc = 500;


    if(g_emMacType == MACHINE_DRAWING)
    {
        //发送下位机
        ParaStruct mcPara = g_pMachine->getMcPara();
        mcPara.buf[150] = kn1Min;
        mcPara.buf[151] = kn1Max;
        mcPara.buf[152] = kn1Acc;
        g_pMachine->setMcPara(&mcPara);//发送下位机

        //写数据
        ui->buttonKn1_MaxSpd->setText(m_speedStr1+QString::number(kn1Max));//最大
        ui->buttonKn1_MinSpd->setText(m_speedStr2+QString::number(kn1Min));//最小
        ui->buttonKn1_AccSpd->setText(m_speedStr3+QString::number(kn1Acc));//加速
    }
    else if(g_emMacType == MACHINE_FLATCUTTINGMAC)
    {
        //发送下位机
        ParaStruct mcPara = g_pMachine->getMcPara();
        mcPara.buf[166] = kn1Min;
        mcPara.buf[167] = kn1Max;
        mcPara.buf[168] = kn1Acc;
        mcPara.buf[170] = kn2Min;
        mcPara.buf[171] = kn2Max;
        mcPara.buf[172] = kn2Acc;
        g_pMachine->setMcPara(&mcPara);//发送下位机

        //写数据
        ui->buttonKn1_MaxSpd->setText(m_speedStr1+QString::number(kn1Max));//刀1最大
        ui->buttonKn1_MinSpd->setText(m_speedStr2+QString::number(kn1Min));//刀1最小
        ui->buttonKn1_AccSpd->setText(m_speedStr3+QString::number(kn1Acc));//刀1加速
        ui->buttonKn2_MaxSpd->setText(tr("Kn2Max:")+QString::number(kn2Max));//刀2最大
        ui->buttonKn2_MinSpd->setText(tr("Kn2Min:")+QString::number(kn2Min));//刀2最小
        ui->buttonKn2_AccSpd->setText(tr("Kn2Acc:")+QString::number(kn2Acc));//刀2加速
    }
}


void PromptDialog::on_buttonFanClose5_clicked()
{

}
